package com.sodaopen.study.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.sodaopen.study.entity.Step;
import com.sodaopen.study.mapper.StepMapper;
import com.sodaopen.study.service.StepService;

@Service
public class StepServiceImpl implements StepService {

	@Autowired
	private StepMapper stepMapper;

	@Override
	public List<Step> findByChapterId(Integer id) {
		return stepMapper.selectByChapterId(id);
	}

	@Override
	public void saveStep(Step step) {
		if(step.getId() == null) {
			stepMapper.insertStep(step);
		}else {
			stepMapper.updateStep(step);
		}
	}

	@Override
	public Integer findMaxSort(Integer chapterId) {
		return stepMapper.selectMaxSort(chapterId);
	}

}
